
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import Node

#获取当前包的安装地址
package_path = get_package_share_directory('scepter_description')
print(package_path)

#读取urdf文件
urdf_path= package_path + '/urdf/so_arm.urdf'
robot_desc=open(urdf_path).read()

def generate_launch_description():

    robot_desc_node=Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        name='robot_state_publisher',
        output='both',
        parameters=[
            {'robot_description': robot_desc},
        ]
    )

    joint_state_pub_node=Node(
        package='joint_state_publisher_gui',
        executable='joint_state_publisher_gui',
    )

    rviz_node=Node(
        package='rviz2',
        executable='rviz2',
        name='rviz',
        arguments=[ '-d', package_path + '/rviz/view.rviz', ]
    )

    return LaunchDescription([
        robot_desc_node,
        joint_state_pub_node,
        rviz_node,
    ])
